import { Router } from "jsr:@oak/oak/router";
import { authMiddleware } from "../middleware/authMiddleware.ts";
import { adminOnly } from "../middleware/adminOnly.ts";
import { getAuth } from "../services/auth.ts";
import type { ApiResponse, AdminUsersData } from "../shared/types.ts";

const router = new Router();

router.get("/api/admin/users", authMiddleware, adminOnly, (ctx) => {
  const auth = getAuth();
  const users = auth.listUsers();
  
  const response: ApiResponse<AdminUsersData> = {
    success: true,
    data: { users }
  };
  
  ctx.response.body = response;
});

export default router; 